//
//  orderDetailVC.m
//  Recycling
//
//  Created by jzd on 2018/5/21.
//  Copyright © 2018年 宋佳. All rights reserved.
//

#import "orderDetailVC.h"
#import "OrderDetailTableViewCell.h"
#import "telCell.h"//电话cell
#import "orderDetailAddressCell.h"//地址cell
#import "AppointmentCell.h"//预约时间cell
#import "RatingTableViewCell.h"//评价cell
#import "pictureViewCell.h"//图片cell
#import "remarkCell.h"//备注

#import "transitionAnnimater.h"//拒绝订单转场
#import "refuseOrderViewController.h"//拒绝订单
#import "cancelOrderViewController.h"//取消订单
#import "selectDateVC.h"//选择时间

#import "orderDetailModel.h"//详情模型

#import "SureCompleteVC.h"//确认完工

#import "roteNavgationController.h"//导航

#import "orderRemarkViewController.h"

#import "PictureSacnViewController.h"//图片浏览器

#import "orderDetailImageListModel.h"

@interface orderDetailVC ()<appointmentCellDelegate,orderDetailAddressOnClickDelegate,remarkDelegate,pictureOnClickDelegate>
@property (strong,nonatomic)NSArray *titleArray;

@property (strong,nonatomic)NSArray *valueArray;
@property(strong,nonatomic)transitionAnnimater *animator;

@property(strong,nonatomic)orderDetailModel *detailModel;
@end

@implementation orderDetailVC
static NSString *const indentifier = @"OrderDetailTableViewCell";
static NSString *const telCellIndentifier = @"telCellIndentifier";
static NSString *const addressIndentifier = @"addressIndentifier";
static NSString *const dateIndentifier = @"dateIndentifier";
static NSString *const ratingIndentifier = @"ratingIndentifier";
static NSString *const pictureTableViewC = @"pictureTableViewC";
static NSString *const remarkDetailCell = @"remarkDetailCell";
-(transitionAnnimater *)animator{
    if (_animator == nil) {
        _animator = [[transitionAnnimater alloc]init];
    }
    return _animator;
}

-(NSArray *)titleArray{
    if (_titleArray == nil) {
        _titleArray = @[@"用户:",@"电话:",@"地址:",@"建单时间:",@"预约时间:",@"催单:",@"工单来源:",@"回收方式:",@"服务项目:",@"作业人员:",@"旧机品类:",@"数量:",@"上门付费:",@"订单状态:",@"订单号:",@"供应厂商:",@"图片:",@"信息费:",@"问题描述:",@"我的备注:",@"评价等级:",@"评价内容:"];
    }
    return _titleArray;
}
-(NSArray *)valueArray{
    if (!_valueArray) {
        NSString *comeFrom = self.detailModel.orderData.ComID == 0 ?@"公众号":self.detailModel.orderData.ComName;
        NSString *servicePro = @"家电回收";
        NSString *typeName = [NSString stringWithFormat:@"%@%@%@",self.detailModel.orderData.ProBrandName,self.detailModel.orderData.ProSpecName,self.detailModel.orderData.ProTypeName];
        NSString * Note = self.detailModel.noteList.count == 0?@"":[(orderDetailNoteListModel *)self.detailModel.noteList.firstObject Note];
        NSString *EvaluateContent = (self.detailModel.orderVisit.EvaluateContent == nil)?@"":self.detailModel.orderVisit.EvaluateContent;
        int score = (self.detailModel.orderVisit.Scode)?self.detailModel.orderVisit.Scode:0;
        _valueArray = @[self.detailModel.orderData.UserName,self.detailModel.orderData.UserTel,self.detailModel.orderData.UserAddress,self.detailModel.orderData.OrderDate,self.detailModel.orderData.AppointmentDate,@(self.detailModel.orderData.RemindCount),comeFrom,self.detailModel.orderData.RecTypeName,servicePro,self.detailModel.orderData.WorkerName,typeName,@(1),[NSString stringWithFormat:@"¥%.2f",self.detailModel.orderData.RecoveryPrice],self.detailModel.orderData.OrderStateName,self.detailModel.orderData.OrderNo,self.detailModel.orderData.BuyPlat,self.detailModel.imgList,[NSString stringWithFormat:@"¥%.2f",self.detailModel.orderData.MessagePrice],self.detailModel.orderData.OrderDesc,Note,@(score),EvaluateContent];
    }
    return _valueArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"工单详情";
    self.view.backgroundColor = BGCOLOR;
    self.tableView.estimatedRowHeight = 40;
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 20, 0);
    
    //根据订单状态判断是否要添加头视图
    //040001002：待接单
    //040001003：进行中
    //040001004：已完工
    if ([self.model.OrderState isEqualToString:@"040001002"]||[self.model.OrderState isEqualToString:@"040001003"]) {
        self.tableView.tableHeaderView = [self getHeaderView];
    }
    
    //最常规的cell
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([OrderDetailTableViewCell class]) bundle:nil] forCellReuseIdentifier:indentifier];
    
    //电话cell
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([telCell class]) bundle:nil] forCellReuseIdentifier:telCellIndentifier];
    //地址 orderDetailAddressCell
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([orderDetailAddressCell class]) bundle:nil] forCellReuseIdentifier:addressIndentifier];
    //修改预约时间
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([AppointmentCell class]) bundle:nil] forCellReuseIdentifier:dateIndentifier];
    //评价
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([RatingTableViewCell class]) bundle:nil] forCellReuseIdentifier:ratingIndentifier];
    //多图片
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([pictureViewCell class]) bundle:nil] forCellReuseIdentifier:pictureTableViewC];
//    [self.tableView registerNib:[[[NSBundle mainBundle]loadNibNamed:@"pictureViewCell" owner:nil options:nil]lastObject] forCellReuseIdentifier:pictureTableViewC];
    //备注
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([remarkCell class]) bundle:nil] forCellReuseIdentifier:remarkDetailCell];
    
    [self getData];
}
-(void)getData{
    NSDictionary *params = @{@"id":@(self.model.ID)};
    
    [[SJNetWorkTool sharedTool]requestWithURLString:orderDetail parameters:params method:GET callBack:^(id responseObject, NSError *error) {
        if (responseObject) {
            int code = [[responseObject objectForKey:@"Code"] intValue];
            NSString *msg = [responseObject objectForKey:@"ErrorMessage"];
            id data = [responseObject objectForKey:@"Data"];
            if (code == 1) {
                if (![data isKindOfClass:[NSNull class]]) {
                    self.detailModel = [orderDetailModel mj_objectWithKeyValues:data];
                   
                    [self.tableView reloadData];
                }else{
                    [self.navigationController.view showToast:@"暂无数据" completion:nil];
                }
            }else{
                [self.navigationController.view showToast:msg completion:nil];
            }
        }
    }];
}
-(UIView *)getHeaderView{
    UIView *header = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 50)];
    header.backgroundColor  = BGCOLOR;
    
    UIButton *leftBut = [UIButton buttonWithType:UIButtonTypeCustom];
    [leftBut setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    leftBut.titleLabel.font = [UIFont systemFontOfSize:15];
    [leftBut addTarget:self action:@selector(headerButtonOnClick:) forControlEvents:UIControlEventTouchUpInside];
    leftBut.layer.cornerRadius = 5;
    leftBut.layer.masksToBounds = YES;
    leftBut.frame = CGRectMake(15, 10, SJScreenW*0.5-30, 30);
    [header addSubview:leftBut];
    
    UIButton *rightBut = [UIButton buttonWithType:UIButtonTypeCustom];
    [rightBut setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    rightBut.titleLabel.font = [UIFont systemFontOfSize:15];
    [rightBut addTarget:self action:@selector(headerButtonOnClick:) forControlEvents:UIControlEventTouchUpInside];
    rightBut.layer.cornerRadius = 5;
    rightBut.layer.masksToBounds = YES;
    rightBut.frame = CGRectMake(SJScreenW*0.5 + 15, 10, SJScreenW*0.5-30, 30);
    [header addSubview:rightBut];
    
    if ([self.model.OrderState isEqualToString:@"040001003"]) {
//        [leftBut setTitle:@"取消" forState:UIControlStateNormal];
//        [leftBut setBackgroundImage:[UIImage imageNamed:@"orange"] forState:UIControlStateNormal];
        
        leftBut.hidden = YES;
        
        [rightBut setTitle:@"完単" forState:UIControlStateNormal];
        [rightBut setBackgroundColor:RGBCOLOR(64, 183, 58)];
        rightBut.frame = CGRectMake(15, 10, SJScreenW-30, 30);
        
    }else{
        [leftBut setTitle:@"拒单" forState:UIControlStateNormal];
        [leftBut setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        leftBut.layer.borderColor = [UIColor darkGrayColor].CGColor;
        leftBut.layer.borderWidth = 1.0;
        
        [rightBut setTitle:@"接单" forState:UIControlStateNormal];
        [rightBut setBackgroundImage:[UIImage imageNamed:@"orange"] forState:UIControlStateNormal];
    }
    
    
    return header;
}
-(void)headerButtonOnClick:(UIButton *)button{
    //拒单
    if ([button.titleLabel.text isEqualToString:@"拒单"]) {
        refuseOrderViewController *vc = [[refuseOrderViewController alloc]init];
        vc.modalPresentationStyle = UIModalPresentationCustom;
        self.animator.torect = CGRectMake(20, SJScreenH*0.5-157, SJScreenW-40, 314);
        vc.transitioningDelegate = self.animator;
        
        vc.model = self.model;
        __block __weak orderDetailVC *Copy_Self = self;
        vc.isSuccess = ^(BOOL isSuccess) {
            if (self.isRefreshView) {
                self.isRefreshView(isSuccess);
            }
            if (isSuccess) {
                [Copy_Self.navigationController popViewControllerAnimated:YES];
                [Copy_Self.navigationController.view showToast:@"拒单成功" completion:nil];
            }else{
                [Copy_Self.navigationController.view showToast:@"拒单失败" completion:nil];
            }
        };
        
        [self presentViewController:vc animated:YES completion:nil];
    }
    //接单
    else if ([button.titleLabel.text isEqualToString:@"接单"]) {
        NSDictionary *params = @{@"id":@(self.model.ID),
                                 @"uid":@([UserInfoTool shareUserInfoTool].Info.ID)
                                 };
        [[SJNetWorkTool sharedTool]requestWithURLString:accessOrder parameters:params method:POST callBack:^(id responseObject, NSError *error) {
            if (responseObject) {
                int code = [[responseObject objectForKey:@"Code"] intValue];
                if (code == 1) {
                    [self.navigationController.view showToast:@"接单成功" completion:^(BOOL didTap) {
                        if (self.isRefreshView) {
                            self.isRefreshView(YES);
                        }
                        [[NSNotificationCenter defaultCenter]postNotificationName:jiedanNotification object:nil];
                        [self.navigationController popViewControllerAnimated:YES];
                    }];
                }else{
                    [self.navigationController.view showToast:@"接单失败" completion:^(BOOL didTap) {
                        if (self.isRefreshView) {
                            self.isRefreshView(NO);
                        }
                    }];
                }
            }
        }];
    }
    //取消
    else if ([button.titleLabel.text isEqualToString:@"取消"]) {
        cancelOrderViewController *vc = [[cancelOrderViewController alloc]init];
        vc.modalPresentationStyle = UIModalPresentationCustom;
        self.animator.torect = CGRectMake(20, SJScreenH*0.5-157, SJScreenW-40, 314);
        vc.transitioningDelegate = self.animator;
        vc.model = self.model;
        __block __weak orderDetailVC *Copy_Self = self;
        vc.isSuccess = ^(BOOL isSuccess) {
            if (self.isRefreshView) {
                self.isRefreshView(isSuccess);
            }
            if (isSuccess) {
                [Copy_Self.navigationController popViewControllerAnimated:YES];
                [Copy_Self.navigationController.view showToast:@"取消成功" completion:nil];
            }else{
                [Copy_Self.navigationController.view showToast:@"取消失败" completion:nil];
            }
        };
        [self presentViewController:vc animated:YES completion:nil];
    }
    //完単
    else if ([button.titleLabel.text isEqualToString:@"完単"]) {
        SureCompleteVC *vc= [[SureCompleteVC alloc]init];
        vc.model = self.model;
        [self.navigationController pushViewController:vc animated:YES];
    }
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
//    [[SJNetWorkTool sharedTool].tasks makeObjectsPerformSelector:@selector(cancel)];
}
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.titleArray.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.row == 1) {
        if (![self.model.OrderState isEqualToString:@"040001002"]) {
            telCell *cell = [tableView dequeueReusableCellWithIdentifier:telCellIndentifier];
            cell.TitleLab.text = [self.titleArray objectAtIndex:indexPath.row];
            if (self.detailModel) {
                [cell.telButton setTitle:[self.valueArray objectAtIndex:indexPath.row] forState:UIControlStateNormal];
                NSString *str = cell.telButton.titleLabel.text;
                NSMutableAttributedString *tncString = [[NSMutableAttributedString alloc]initWithString:str];
                [tncString addAttribute:NSUnderlineStyleAttributeName
                                  value:@(NSUnderlineStyleSingle)
                                  range:(NSRange){0,[tncString length]}];
                //此时如果设置字体颜色要这样
                [tncString addAttribute:NSForegroundColorAttributeName value:TITLECOLOR  range:NSMakeRange(0,[tncString length])];
                
                //设置下划线颜色...
                [tncString addAttribute:NSUnderlineColorAttributeName value:TITLECOLOR range:(NSRange){0,[tncString length]}];
                [cell.telButton setAttributedTitle:tncString forState:UIControlStateNormal];
            }else{
                [cell.telButton setTitle:@"" forState:UIControlStateNormal];
            }
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
        }else{
            OrderDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifier];
            cell.titleLa.text = [self.titleArray objectAtIndex:indexPath.row];
            if (self.detailModel) {
                cell.containerLa.text = [self.valueArray objectAtIndex:indexPath.row];
            }else{
                cell.containerLa.text = @"";
            }
            cell.titleLa.textColor = [UIColor darkGrayColor];
            cell.containerLa.textColor = [UIColor darkGrayColor];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
        }
    }
    if (indexPath.row == 2) {
        if (![self.model.OrderState isEqualToString:@"040001002"]) {
            orderDetailAddressCell *cell = [tableView dequeueReusableCellWithIdentifier:addressIndentifier];
            cell.titleLab.text = [self.titleArray objectAtIndex:indexPath.row];
            cell.delegate = self;
            if (self.detailModel) {
                [cell.addressBut setTitle:[self.valueArray objectAtIndex:indexPath.row] forState:UIControlStateNormal];
            }else{
                [cell.addressBut setTitle:@"" forState:UIControlStateNormal];
            }
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
        }else{
            OrderDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifier];
            cell.titleLa.text = [self.titleArray objectAtIndex:indexPath.row];
            if (self.detailModel) {
                cell.containerLa.text = [self.valueArray objectAtIndex:indexPath.row];
            }else{
                cell.containerLa.text = @"";
            }
            cell.titleLa.textColor = [UIColor darkGrayColor];
            cell.containerLa.textColor = [UIColor darkGrayColor];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
        }
    }
    if (indexPath.row == 4) {
        if ([self.model.OrderState isEqualToString:@"040001003"]) {
            AppointmentCell *cell = [tableView dequeueReusableCellWithIdentifier:dateIndentifier];
            cell.titleLab.text = [self.titleArray objectAtIndex:indexPath.row];
            if (self.detailModel) {
                cell.dateLab.text = [self.valueArray objectAtIndex:indexPath.row];
            }else{
                cell.dateLab.text = @"";
            }
            cell.delegate = self;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
        }else{
            OrderDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifier];
            cell.titleLa.text = [self.titleArray objectAtIndex:indexPath.row];
            if (self.detailModel) {
                cell.containerLa.text = [self.valueArray objectAtIndex:indexPath.row];
            }else{
                cell.containerLa.text = @"";
            }
            cell.titleLa.textColor = [UIColor darkGrayColor];
            cell.containerLa.textColor = [UIColor darkGrayColor];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
        }
    }
    
    if (indexPath.row == self.titleArray.count-2) {
        RatingTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ratingIndentifier];
        cell.titleLab.text = [self.titleArray objectAtIndex:indexPath.row];
        if (self.detailModel) {
            cell.score = [[self.valueArray objectAtIndex:indexPath.row] intValue];
        }else{
            cell.score = 0;
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
    if (indexPath.row == self.titleArray.count-3) {
        if (![self.model.OrderState isEqualToString:@"040001002"]) {
            remarkCell *cell = [tableView dequeueReusableCellWithIdentifier:remarkDetailCell];
            [cell.leftBut setTitle:[self.titleArray objectAtIndex:indexPath.row] forState:UIControlStateNormal];
            if (self.detailModel) {
                if ([[self.valueArray objectAtIndex:indexPath.row] isEqualToString:@""]) {
                    [cell.valueBut setTitle:@"无" forState:UIControlStateNormal];
                }else{
                    [cell.valueBut setTitle:[self.valueArray objectAtIndex:indexPath.row] forState:UIControlStateNormal];
                }
                
            }else{
                [cell.valueBut setTitle:@"无" forState:UIControlStateNormal];
            }
            cell.delegate =self;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
        }else{
            OrderDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifier];
            cell.titleLa.text = [self.titleArray objectAtIndex:indexPath.row];
            if (self.detailModel) {
                cell.containerLa.text = [self.valueArray objectAtIndex:indexPath.row];
            }else{
                cell.containerLa.text = @"";
            }
            cell.titleLa.textColor = [UIColor darkGrayColor];
            cell.containerLa.textColor = [UIColor darkGrayColor];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
        }
    }
    if (indexPath.row == 16) {
        pictureViewCell *cell = [tableView dequeueReusableCellWithIdentifier:pictureTableViewC];
        cell.titleLab.text = [self.titleArray objectAtIndex:indexPath.row];
        if (self.detailModel) {
            cell.images = [self.valueArray objectAtIndex:indexPath.row];
        }
        cell.delegate =self;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
    
    OrderDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifier];
    if (indexPath.row == 5) {
        cell.titleLa.textColor = [UIColor redColor];
        cell.containerLa.textColor = [UIColor redColor];
    }else{
        cell.titleLa.textColor = [UIColor darkGrayColor];
        cell.containerLa.textColor = [UIColor darkGrayColor];
    }
    cell.titleLa.text = [self.titleArray objectAtIndex:indexPath.row];
    if (self.detailModel) {
        if ([cell.titleLa.text isEqualToString:@"信息费:"] && self.detailModel.IsShowMsgPrice == 1) {
            cell.containerLa.text = @"";
        }else{
            cell.containerLa.text = ([[self.valueArray objectAtIndex:indexPath.row] isKindOfClass:[NSString class]])?[self.valueArray objectAtIndex:indexPath.row]:[[self.valueArray objectAtIndex:indexPath.row]stringValue];
        }
    }else{
        cell.containerLa.text = @"";
    }
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
//备注被点击
-(void)remarkButtonOnClick:(UIButton *)button{
    //进行中
    if ([self.model.OrderState isEqualToString:@"040001003"]) {
        orderRemarkViewController *vc = [[orderRemarkViewController alloc]init];
        vc.modalPresentationStyle = UIModalPresentationCustom;
        self.animator.torect = CGRectMake(20, SJScreenH*0.5-190, SJScreenW-40, 380);
        vc.transitioningDelegate = self.animator;
        
        vc.model = self.model;
        __block __weak orderDetailVC *Copy_Self = self;
        vc.isSuccess = ^(BOOL isSuccess) {
            __strong typeof (Copy_Self) strongSelf = Copy_Self;
            if (isSuccess) {
                [strongSelf getData];
                [strongSelf.navigationController.view showToast:@"提交备注成功" completion:nil];
            }else{
                [strongSelf.navigationController.view showToast:@"提交备注失败" completion:nil];
            }
        };
        [self presentViewController:vc animated:YES completion:nil];
    }else{
        //已完成
    }
}
//地址被点击
-(void)orderDetailAddressCell:(orderDetailAddressCell *)cell OnClick:(UIButton *)button{
    roteNavgationController *vc = [[roteNavgationController alloc]init];
    vc.goAddressStr = cell.addressBut.titleLabel.text;
    [self.navigationController pushViewController:vc animated:YES];
}
//更改时间按钮
-(void)timeOnClick:(UILabel *)dateL{
    selectDateVC *vc = [[selectDateVC alloc]init];
    vc.modalPresentationStyle = UIModalPresentationCustom;
    vc.transitioningDelegate  = self.animator;
    self.animator.torect = CGRectMake(0, SJScreenH-260, SJScreenW, 260);
    vc.datePickerMode = UIDatePickerModeDateAndTime;
    vc.minDate = [NSDate date];
    __block __weak orderDetailVC *copy_self = self;
    vc.dateBlock = ^(NSString *date) {
        dateL.text = date;
        [copy_self replaceTime:date];
    };
    [self presentViewController:vc animated:YES completion:nil];
}
-(void)replaceTime:(NSString *)time{
    NSDictionary *params = @{@"id":@(self.model.ID),
                             @"uid":@([UserInfoTool shareUserInfoTool].Info.ID),
                             @"applydate":time
                             };
    [[SJNetWorkTool sharedTool]requestWithURLString:changeApplyTime parameters:params method:POST callBack:^(id responseObject, NSError *error) {
        if (responseObject) {
            int code = [[responseObject objectForKey:@"Code"] intValue];
            NSString *msg = [responseObject objectForKey:@"ErrorMessage"];
            if (code == 1) {
                if (self.isRefreshView) {
                    self.isRefreshView(YES);
                }
                [self.navigationController.view showToast:@"修改预约时间成功" completion:nil];
            }else{
                [self.navigationController.view showToast:@"修改预约时间失败" completion:nil];
            }
            SJLog(@"%@",msg);
//            [self.navigationController.view showToast:msg completion:nil];
        }
    }];
}

//图片呗点击
-(void)pictureViewCell:(pictureViewCell *)cell pictureOnClick:(NSInteger)index{
    SJLog(@"%@",cell.images);
    PictureSacnViewController *picVC=[PictureSacnViewController new];
    
    NSMutableArray *array=[NSMutableArray array];
    
    for(int i=0;i<cell.images.count;i++){
        orderDetailImageListModel *model = (orderDetailImageListModel *)[cell.images objectAtIndex:i];
        NSMutableDictionary *dic=[NSMutableDictionary dictionary];
        [dic setObject:@"0" forKey:@"islocal"];
        [dic setObject:@"8" forKey:@"text"];
        [dic setObject:model.ImgUrl forKey:@"picString"];
        [array addObject:dic];
    }
    picVC.picArray=[NSMutableArray arrayWithArray:array];
    picVC.currenpage=index+1;//当前图片
    [self.navigationController presentViewController:picVC animated:YES completion:nil];
}
-(void)dealloc{
    SJLog(@"详情挂了");
}
-(void)dismissAA{
    [self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}
@end
